<?php

class OOWP_Atom_WidgetArea
    extends OOWP_Formattable
{

    public function __construct($name)
    {
        parent::__construct(array(
            'name' => $name,
        ));
    }

    /* ACCESSORS */

    protected function getName( )
    {
        return $this->dict['name'];
    }

    protected function setName($name)
    {
        if (OOWP_Base::is_wellformed_string($name)) {
            $this->dict['name'] = $name;
        }
    }

    protected function getFormatPieces( )
    {
        ob_start();

        if ($this->name) {
            dynamic_sidebar($this->name);
        } else {
            dynamic_sidebar( );
        }

        $capture = ob_get_contents();
        ob_end_clean();

        $result = str_replace("\n", "\t", $capture);
        $result = explode("\t", $result);
        $result = array_map("trim", $result);
        $result = array_filter($result, "strlen");

        return $result;
    }

}
